set(target "${GDMPComponentsPrefix}Plugin")

set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

add_library(${target} SHARED)

# 设置所在文件夹
set_target_properties(${target} PROPERTIES
    FOLDER "${GDMPComponentsSampleFolder}"
    OUTPUT_NAME "GDMPComponentsSamplePlugin"
)

file(GLOB_RECURSE SOURCE_FILES
    LIST_DIRECTORIES False CONFIGURE_DEPENDS
    "${SOURCE_DIR}/*.h*"
    "${SOURCE_DIR}/*.c*"
)

target_sources(${target} PRIVATE
    ${SOURCE_FILES}
)

find_package(Qt5 COMPONENTS Widgets REQUIRED)
target_link_libraries(${target} PRIVATE
    "${GDMPComponentsPrefix}UiAdapter"

    Gcmp::All
    Gdmp::foundation
    Gdmp::drawing
    Gdmp::modeling
    Gdmp::drawing.db
    Gdmp::foundation.db
    Qt5::Widgets
)

# 拷贝addin等插件文件到指定插件目录
if(GDMPComponentsAddinFolders)
    foreach(folder ${GDMPComponentsAddinFolders})
        add_custom_command(TARGET ${target} POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/${folder}/
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/${folder}/
        )
    endforeach()
endif()

DeployGdmpRuntime(${target})
